{% extends 'base.html' %}
{% load static %}
{% load user_filter %}
{% block title %}日志记录{% endblock %}
{% block custome_css %}
{% endblock %}
{% block content %}
    <div class="card card-mb0">

        <div class="card-toolbar clearfix">

            <!-- 搜索表单 -->
            {% if request|has_permission:'search' %}
            <form class="pull-right search-bar" method="get" action="" role="form">
                <div class="input-group input-group-sm">
                    <input type="text" class="form-control" placeholder="请输入关键词..."
                           name="search" value="{% if h_search %}{{ h_search }}{% endif %}">
                    <span class="input-group-btn">
                      <button type="submit" class="btn btn-success" title="点击开始搜索">搜索</button>
                    </span>
                </div>
            </form>
            {% endif %}

        </div>

        <div class="card-body card-body-p0">

            <!-- 表格 -->
            <table class="table table-striped table-bordered table-hover table-condensed table-one">
                <thead>
                    <tr>
                        <th style="text-align: center">序号</th>
                        <th>请求模块</th>
                        <th>请求地址</th>
                        <th>请求参数</th>
                        <th>请求方式</th>
                        <th>操作说明</th>
                        <th>请求ip地址</th>
                        <th>请求浏览器</th>
                        <th>响应状态码</th>
                        <th>操作系统</th>
                        <th>返回信息</th>
                        <th>响应状态</th>
                        <th>操作人</th>
                        <th>操作时间</th>
                    </tr>
                </thead>
                <tbody>
                {% for obj in p_objs.object_list %}
                    <tr>
                        <td style="text-align: center">{{ forloop.counter|add:p_start }}</td>
                        <td>{{ obj.request_modular|default_if_none:'' }}</td>
                        <td>{{ obj.request_path|default_if_none:'' }}</td>
                        <td>{{ obj.request_body|default_if_none:'' }}</td>
                        <td>{{ obj.request_method|default_if_none:'' }}</td>
                        <td>{{ obj.request_msg|default_if_none:'' }}</td>
                        <td>{{ obj.request_ip|default_if_none:'' }}</td>
                        <td>{{ obj.request_browser|default_if_none:'' }}</td>
                        <td>{{ obj.response_code|default_if_none:'' }}</td>
                        <td>{{ obj.request_os|default_if_none:'' }}</td>
                        <td>{{ obj.json_result|default_if_none:'' }}</td>
                        <td>
                            {% ifequal obj.status 1 %}
                                <span class="text-success">{{ obj.status }}</span>
                            {% else %}
                                <span class="text-danger">{{ obj.status }}</span>
                            {% endifequal %}
                        </td>
                        <td>{{ obj.creator|default_if_none:'' }}</td>
                        <td>{{ obj.create_datetime|date:"Y-m-d H:i:s" }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>

            <!-- 表格分页 -->
            <div class="table-pagination">
                <span>显示 {{ p_objs.start_index }} - {{ p_objs.end_index }} ，&nbsp;共 {{ p_sum }} 项</span>
                <ul class="pagination">
                    {% if p_objs.has_previous %}
                        <li><a href="?{{ p_objs.previous_page_number.querystring }}">&laquo;</a></li>
                    {% else %}
                        <li><a href="javascript:return false;" style="cursor: not-allowed;"><i style="opacity: 0.2">&laquo;</i></a>
                        </li>
                    {% endif %}
                    {% for page in p_objs.pages %}
                        {% if page %}
                            {% ifequal page p_objs.number %}
                                <li class="active"><a href="?{{ page.querystring }}">{{ page }}</a></li>
                            {% else %}
                                <li><a href="?{{ page.querystring }}">{{ page }}</a></li>
                            {% endifequal %}
                        {% else %}
                            <li><a>...</a></li>
                        {% endif %}
                    {% endfor %}
                    {% if p_objs.has_next %}
                        <li><a href="?{{ p_objs.next_page_number.querystring }}">&raquo;</a></li>
                    {% else %}
                        <li><a href="javascript:return false;" style="cursor: not-allowed;"><i style="opacity: 0.2">&raquo;</i></a>
                        </li>
                    {% endif %}
                </ul>
            </div>

        </div>

    </div>
{% endblock %}